package com.itheima.jobs;

import com.itheima.constant.QiniuUtils;
import com.itheima.constant.RedisConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPool;

import java.util.Set;

/**
 * <h3>health94_pareant</h3>
 * <p></p>
 *
 * @author : hhw
 * @date : 2020-03-22 15:15
 **/

@Component("myQuartz")
public class DeletePicTiming {

    @Autowired
    private JedisPool jedisPool;

    public void deletePicTiming(){
        System.out.println("我执行了");
        Set<String> diffImg = jedisPool.getResource().sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);


        for (String s : diffImg) {
            //从七牛云删除图片
            QiniuUtils.deleteFileFromQiniu(s);
            //从redis删除多余图片
            jedisPool.getResource().srem(RedisConstant.SETMEAL_PIC_RESOURCES, s);
        }
    }
}
